package com.ruoyi.controller;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.demo.StudentInfo;
import com.ruoyi.service.StudentinfoSerive;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
@RestController
@RequestMapping("/Studentinfo")
public class studentInfoController {

    @Resource
    private StudentinfoSerive service;




    @GetMapping("/list")
    public List<StudentInfo> list() {
        List<StudentInfo> list = service.list();
        return list;
    }

    @GetMapping("/al")
    public int al() {
        int count = Integer.parseInt(service.al());
        return count;
    }

    @GetMapping("/getlist")
    public AjaxResult getList(@RequestParam("age") String age, @RequestParam(value = "id",required = false)Integer id){
        List<StudentInfo> list = service.getList(age,id);
        return AjaxResult.success();
    }

    @DeleteMapping("delete")
    public AjaxResult delete(Integer id){
        service.delete(id);
        return AjaxResult.success();
    }


    @PostMapping("/create")
    public AjaxResult create(StudentInfo info){
        service.create(info);
        return AjaxResult.success();
    }


    @PostMapping("/InsertStudent")
    public AjaxResult InsertStudent(StudentInfo info){
        service.InsertStudent(info);
        return AjaxResult.success();
    }

    @DeleteMapping("/deleteIds")
    public AjaxResult deleteIds(Integer[] ids){
        service.deleteIds(ids);
        return AjaxResult.success();
    }





    //增删改查

    @RestController
    @RequestMapping("/Student02")
    public class Student02   {

        @Resource
        private StudentinfoSerive service;


        @GetMapping("/list")
        public List<StudentInfo> list(){
            List<StudentInfo> list = service.list();
            return list;
        }

    }
}



